    import { reqCategoryList,reqBannerList, reqFloorList } from "@/api"

    //state：仓库存储数据的地方
    const state = {
            categoryList: [],
            bannerList:[],
            floorList:[],
        }
    //mutation:修改state的唯一手段
    const mutations = {
            CATEGORYLIST(state, categoryList) {
                state.categoryList = categoryList
            },
            BANNERLIST(state,bannerList){
                state.bannerList = bannerList
            },
            FLOORLIST(state,floorList){
                state.floorList = floorList
            }
        }
        //action:书写业务逻辑，处理异步
    const actions = {
            //三级联动商品列表
            async categoryList({ commit }) {
                let re = await reqCategoryList()
                if (re.code == 200) {
                    commit('CATEGORYLIST', re.data)
                }
            },
            //轮播图数据
            async bannerList({commit}){
                let re = await reqBannerList()
                if (re.code == 200){
                    commit('BANNERLIST',re.data)
                }
            },
            //floor 楼层数据
            async floorList({commit}){
                let re = await reqFloorList()
                if (re.code == 200){
                    commit('FLOORLIST',re.data)
                }
            }
        }
        //getters 简化仓库数据，组件获取仓库数据更加方便
    const getters = {}
    export default {
        state,
        mutations,
        actions,
        getters
    }